package day0321;

import java.util.Arrays;

public class Test3 {
    public static void main(String[] args) {
        //1.定义一个ar1数组,里边存储5个整数
        int[]  ar1={1,6,8,4,7};
        int delIndex=2;//delIndex表示要删除的元素序号
        //2.将ar1[length-1]元素放入到ar1[delIndex]位置
        ar1[delIndex]=ar1[ar1.length-1];
        //3. 用 ar1=Arrays.copyOf();对ar1数组缩容(比原本的长度少一位)
        ar1= Arrays.copyOf(ar1, ar1.length-1);
        //打印ar1数组
        System.out.println(Arrays.toString(ar1));
    }
}
